package com.auth.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;

@Configuration
@EnableCaching
public class CacheConfiguration {


    @Autowired
    private JedisConnectionFactory factory;
    /**
     * @author enzo
     * @date 2018/10/14 下午3:16
     * @todo cache manager
     * @param
     * @throws
     * @return
     * @remark
     */
    @Bean
    public CacheManager cacheManager(){
        return RedisCacheManager
                .RedisCacheManagerBuilder
                .fromConnectionFactory(factory)
                .build();
    }
}